package com.clouddot.baipai.ui.fragment.V_MainFragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.clouddot.baipai.R;
import com.clouddot.baipai.infrastructure.environment.Env;
import com.clouddot.baipai.model.beam.PRaise.PRaiseResponse;
import com.clouddot.baipai.model.beam.getPersonInfo.getPersonInfoResponse;
import com.clouddot.baipai.ui.adapter.V_Adapter.PRaiseAdapter;
import com.clouddot.baipai.ui.fragment.BaseFragment;
import com.clouddot.baipai.ui.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wxy on 2018/4/10.
 */

public class V_PRaiseFragment extends BaseFragment {

    private View view;
    private Context context;
    private RelativeLayout loadingP;
    private RecyclerView recyclerView;
    private ImageView loading;
    private PRaiseAdapter adapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        return view;
    }

    @Override
    protected void setContentView() {
        super.setContentView();
            view = LayoutInflater.from(context).inflate(R.layout.v_f_praisefg,null);

    }

    @Override
    protected void initControls() {
        super.initControls();
        loadingP = view.findViewById(R.id.loading);
        loading = view.findViewById(R.id.imgloading);
        recyclerView = view.findViewById(R.id.recycleView);
        LinearLayoutManager mLayoutManager=new LinearLayoutManager(getActivity());
        mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(mLayoutManager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        List<PRaiseResponse> raiseResponseList = new ArrayList<>();
        PRaiseResponse item1 = new PRaiseResponse();
        PRaiseResponse item1Other = new PRaiseResponse();
        PRaiseResponse item2 = new PRaiseResponse();
        PRaiseResponse item3 = new PRaiseResponse();
        item1.setName("张三");
        item1Other.setName("李四");
        item2.setName("张三");
        item3.setName("张三");
        item1.setDate("2018-12-12");
        item1.setWeek("星期一");
        item2.setWeek("星期一");
        item3.setWeek("星期一");
        item2.setDate("2018-12-12");
        item3.setDate("2018-12-12");

        item1.setInfo("哈哈哈哈哈哈");
        item2.setInfo("哈哈哈哈哈哈哈哈哈哈哈哈");
        item3.setInfo("哈哈哈哈哈哈哈哈哈哈哈哈");
        item1Other.setInfo("哈哈哈哈哈哈啊啊");

        item1.setItemType(PRaiseResponse.pRaiseTop);
        item1Other.setItemType(2);
        item2.setItemType(1);
        item3.setItemType(1);
        raiseResponseList.add(item1);
        raiseResponseList.add(item1Other);
        raiseResponseList.add(item2);
        raiseResponseList.add(item3);
        adapter = new PRaiseAdapter(raiseResponseList);
        adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
            }
        });

        recyclerView.setAdapter(adapter);
    }


    @Override
    protected void setListener() {
        super.setListener();

    }


    @Override
    protected void loadParams() {
        super.loadParams();
    }

    @Override
    public void onAttach(Context context) {
        this.context = context;
        super.onAttach(context);
    }

    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void runThreadAction() {
        super.runThreadAction();
    }

    @Override
    protected Object runThreadActionExceute() {
         super.runThreadActionExceute();
        return Env.getAppPresenter().getPersonInfo();
    }

    @Override
    protected void runThreadActionSuccess(Object result) {
        super.runThreadActionSuccess(result);

    }

    @Override
    protected void runThreadActionError(Exception ex) {
        super.runThreadActionError(ex);
    }


}
